'use strict';

angular.module('app')
    .controller('tradeFlowController', [ '$rootScope', '$scope', '$http', '$state',
        function($rootScope, $scope, $http, $state) {
            $scope.title = '流水列表';
            $scope.param = { };
            $scope.loading = false;
            $scope.param.userId = $state.params.userIds;
            $scope.search = function () {
                $scope.loading = true;
                $scope.param.applyStartdate = $("#applyStartdate").val();
                $scope.param.applyEnddate = $("#applyEnddate").val();
                $scope.param.examineStartdate = $("#examineStartdate").val();
                $scope.param.examineEnddate = $("#examineEnddate").val();
                $.ajax({
                    url : $scope.app.project_name+'/userWallet/tradeFlowList',
                    data: $scope.param
                }).then(function(result) {
                    console.log($state);
                    $scope.loading = false;
                    if (result.httpCode == 200) {
                        $scope.pageInfo = result.data;
                    } else {
                        $scope.msg = result.msg;
                    }
                    $scope.$apply();
                });
            }


            $scope.searchRe = function () {
                $scope.loading = true;
                $scope.param.pageNum = 1;
                $scope.param.applyStartdate = $("#applyStartdate").val();
                $scope.param.applyEnddate = $("#applyEnddate").val();
                $scope.param.examineStartdate = $("#examineStartdate").val();
                $scope.param.examineEnddate = $("#examineEnddate").val();
                $.ajax({
                    url : $scope.app.project_name+'/userWallet/tradeFlowList',
                    data: $scope.param
                }).then(function(result) {
                    $scope.loading = false;
                    if (result.httpCode == 200) {
                        $scope.pageInfo = result.data;
                    } else {
                        $scope.msg = result.msg;
                    }
                    $scope.$apply();
                });
            }

            $scope.search();

            $scope.clearSearch = function() {
                $("#applyStartdate").val("");
                $("#applyEnddate").val("");
                $("#examineStartdate").val("");
                $("#examineEnddate").val("");
                $scope.param={};
                $scope.search();
            }



            // 翻页
            $scope.pagination = function (page) {
                $scope.param.pageNum=page;
                $scope.search();
            };
        } ]);